package com.zhang.controller;

import com.zhang.constant.MqConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SimulateQuartzController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    //1.发送上架秒杀商品的通知
    @GetMapping("sendMsgToScanSeckill")
    public String sendMsgToScanSeckill(){
        //发送消息只起到一个通知作用
        rabbitTemplate.convertAndSend(MqConst.SCAN_SECKILL_EXCHANGE,MqConst.SCAN_SECKILL_ROUTE_KEY,"xxx");
        return "success";
    }

    //2.发送下架秒杀商品的通知
    @GetMapping("sendMsgToClearSeckill")
    public String sendMsgToClearSeckill(){
        //发送消息只起到一个通知作用
        rabbitTemplate.convertAndSend(MqConst.CLEAR_REDIS_EXCHANGE,MqConst.CLEAR_REDIS_ROUTE_KEY,"xxx");
        return "success";
    }
}
